#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import time
from engine.common import *
from shutil import copyfile
if sys.platform == "darwin":
    adbpath = "adb "
else:
    adbpath = "/usr/bin/adb "
if (sys.argv.__len__())<7:
    print( "参数个数少了")
    exit(0)
handset = sys.argv[1]
currentHandsetSnumber = sys.argv[2]
command = sys.argv[3]
resultF = sys.argv[4]

filePathLoc = sys.argv[5]
tempFile = sys.argv[6]


def copyTKLAndSave( handset,currentHandsetSnumber,resultF,filePathLoc="/temp/",tklFile="./temp/复制淘口令.txt",delay=5 ):
    ret = False
    setHandsetType(handset)
    setHandsetSno(currentHandsetSnumber)
    content = getAndSetMsgFromHandsetCliper("test",currentHandsetSnumber)
    # content = content.split("，")[1]
    # content = content.replace('¥',"")
    # content = content.replace("$","")
    # content = '--------------[nr]{['+content+']}复制这条信息，打开【Táo宝】查看[玫瑰]'
    if not os.path.exists(getHandsetFileSavePath(filePathLoc)):
        os.makedirs(getHandsetFileSavePath(filePathLoc))

    with open(getHandsetFileSavePath(tklFile),'w') as f:
        print('wriete to file'+content)
        f.write(content)

    with open(getHandsetFileSavePath(resultF),'w')as f:
        if ret == True:
            f.write('True')
            return True  #TRUE 状态转移
        else:
            f.write('False')
            return False


if command =="copyTKLAndSave".strip():
    copyTKLAndSave(handset,currentHandsetSnumber,resultF,filePathLoc,tempFile)
